package com.husd.framework.xml;

import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
import lombok.Data;

import java.util.List;

/**
 * @author shengdonghu@126.com
 * @date 2023/10/25 15:36
 */
@Data
@JacksonXmlRootElement(localName = "ProductPackage")
public class ProductPackage {
    @JacksonXmlProperty(localName = "Name", isAttribute = true)
    private String name;
    @JacksonXmlProperty(localName = "ProductPackage.Products")
    private ProductPackageProducts productPackageProducts;

    @Data
    @JacksonXmlRootElement(localName = "ProductPackage.Products")
    public class ProductPackageProducts {
        @JacksonXmlProperty(localName = "ProductCollection")
        private ProductCollection productCollection;

        @Data
        @JacksonXmlRootElement(localName = "ProductCollection")
        public class ProductCollection {
            @JacksonXmlProperty(localName = "Capacity", isAttribute = true)
            private String capacity;
            @JacksonXmlElementWrapper(useWrapping = false)
            @JacksonXmlProperty(localName = "Product")
            private List<Product> product;

            @Data
            @JacksonXmlRootElement(localName = "Product")
            public class Product {
                /**
                 * Product variants 变体
                 */
                @JacksonXmlProperty(localName = "SellerProductId", isAttribute = true)
                private String sellerProductId;
                @JacksonXmlProperty(localName = "BrandName", isAttribute = true)
                private String brandName;
                @JacksonXmlProperty(localName = "ProductKind", isAttribute = true)
                private String productKind;
                @JacksonXmlProperty(localName = "CategoryCode", isAttribute = true)
                private String categoryCode;
                @JacksonXmlProperty(localName = "ShortLabel", isAttribute = true)
                private String shortLabel;
                @JacksonXmlProperty(localName = "LongLabel", isAttribute = true)
                private String longLabel;
                @JacksonXmlProperty(localName = "Description", isAttribute = true)
                private String description;
                @JacksonXmlProperty(localName = "SellerProductFamily", isAttribute = true)
                private String sellerProductFamily;
                @JacksonXmlProperty(localName = "Size", isAttribute = true)
                private String size;
                @JacksonXmlProperty(localName = "SellerProductColorName", isAttribute = true)
                private String sellerProductColorName;
                @JacksonXmlProperty(localName = "Model", isAttribute = true)
                private String model;
                @JacksonXmlProperty(localName = "Navigation", isAttribute = true)
                private String navigation;
                @JacksonXmlProperty(localName = "Product.EanList")
                private ProductEanList productEanList;

                @Data
                @JacksonXmlRootElement(localName = "Product.EanList")
                public class ProductEanList {
                    @JacksonXmlProperty(localName = "ProductEan")
                    private ProductEan productEan;

                    @Data
                    @JacksonXmlRootElement(localName = "ProductEan")
                    public class ProductEan {
                        @JacksonXmlProperty(localName = "Ean", isAttribute = true)
                        private String ean;
                        @JacksonXmlText
                        private String value;
                    }

                }

                @JacksonXmlProperty(localName = "Product.ModelProperties")
                private ProductModelProperties productModelProperties;

                @Data
                @JacksonXmlRootElement(localName = "Product.ModelProperties")
                public class ProductModelProperties {
                    @JacksonXmlElementWrapper(useWrapping = false)
                    @JacksonXmlProperty(localName = "String")
                    private List<ProductModelPropertiesString> productModelPropertiesString;

                    @Data
                    @JacksonXmlRootElement(localName = "String")
                    public class ProductModelPropertiesString {
                        @JacksonXmlProperty(localName = "Key", isAttribute = true)
                        private String key;
                        @JacksonXmlText
                        private String value;
                    }

                }

                @JacksonXmlProperty(localName = "Product.Pictures")
                private ProductPictures productPictures;

                @Data
                @JacksonXmlRootElement(localName = "Product.Pictures")
                public class ProductPictures {
                    @JacksonXmlProperty(localName = "ProductImage")
                    private ProductImage productImage;

                    @Data
                    @JacksonXmlRootElement(localName = "ProductImage")
                    public class ProductImage {
                        @JacksonXmlProperty(localName = "Uri", isAttribute = true)
                        private String uri;
                        @JacksonXmlText
                        private String value;
                    }

                }

            }

        }

    }

}